package com.systop.scos.news.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Store;

import com.systop.common.modules.security.user.model.User;
import com.systop.core.model.BaseModel;

/**
 * 新闻类别
 * 
 * @author ShangHua
 * 
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "news_comments")
public class NewsComment extends BaseModel {
	
	/** 主键 */
	private Integer id;

	/** 内容 */
	private String content;
	
	/** 评论人 */
	private User commenter;
	
	/** 创建时间 */
	private Date createTime;
	
	/** 新闻 */
	private News news;

	public NewsComment() {
	}

	@Id
	@GeneratedValue(generator = "hibseq")
	@GenericGenerator(name = "hibseq", strategy = "hilo")
	@Column(name = "id", nullable = false)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

  @Column(name = "Content")
  @Type(type = "text")
  @Field(name = "content", index = Index.TOKENIZED, store = Store.YES)
	public String getContent() {
		return this.content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumn(name = "Commenter")
	public User getCommenter() {
		return commenter;
	}

	public void setCommenter(User commenter) {
		this.commenter = commenter;
	}
	
	@Column(name = "Create_Time")
	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumn(name = "News_Id")
	public News getNews() {
		return news;
	}

	public void setNews(News news) {
		this.news = news;
	}
	
}
